<?php
// 测试文件,请在命令行下执行
include_once(dirname(__FILE__)."/../inc/common.php");

echo "\n[config]\n";
config::set("mysql_log_callback", "mysql_log");
config::set(array(
    "template_path" => dirname(__FILE__)."/tpl",
    "template_cache_path" => dirname(__FILE__)."/tpl_c"
));
var_dump(config::get());
var_dump(config::get("template_path"));

echo "\n[mysql]\n";
function mysql_log($query_info) {
    echo "# log callback start\n";
    var_dump($query_info);
    echo "# log callback end\n";
}
mysql::add_db(array(
    "id" => 1,
    "host" => "localhost",
    "port" => 3306,
    "user" => "root",
    "pass" => "",
    "name" => "mysql"
));
mysql::$log_callback = config::get("mysql_log_callback");
$res = mysql::query("select version() as ver", 1);
var_dump($res);
var_dump(mysql::get_query_info());
mysql::remove_db(0);

echo "\n[template]\n";
template::$path = config::get("template_path");
template::$cache_path = config::get("template_cache_path");
template::assign("php_version", PHP_VERSION);
var_dump(template::get_assign_data());
var_dump(template::display("index.html", 1));
var_dump(template::get_error());

echo "\n[file_cache]\n";
file_cache::$path = dirname(__FILE__)."/cache";
file_cache::set("php_version", PHP_VERSION);
var_dump(file_cache::get("php_version"));

echo "\n[file_log]\n";
file_log::$path = dirname(__FILE__)."/log";
// file_log::$mode = file_log::mode_day;
file_log::save("index", "uid=1|action=db_query|query_str=show tables");
echo file_log::$path."\n";

